Lightwave Lab, Princeton University
Oct 31st, 2019
https://github.com/thomaslima/2019-siepic-workshop-zeropdk
Email: tlima@princeton.edu
Computer-aided layout
Procedural layout
# make_chip.py
FLOORPLAN_SAFE = 50
TECHNOLOGY = TECHNOLOGY.layers # TODO refactor
if __name__ == "__main__":
layout = pya.Layout()
dbu = layout.dbu = 0.001
TOP = layout.create_cell("TOP")
origin = pya.DPoint(0, 0)
ex = pya.DVector(1, 0)
ey = rotate90(ex)
# FLOORPLAN
FX, FY = 7850, 3000 # um
layout_box(TOP, layout.layer(TECHNOLOGY["FloorPlan"]),
origin, origin + FX * ex + FY * ey, ex)
# Placing each experiment
placement_list = {
"FeedbackWeightBank_experiment": (
exp.FeedbackWeightBank_experiment, # PCell class
2792.04000, 328.87000, # position
{"angle_ex": 90, "N": 5}, # parameters
),
# ...
}
# Place all PCells in placement_list and export port locations for routing
for name, (klass, x, y, params) in placement_list.items():
exp_ports[name] = klass(name, params=params).place_cell(
TOP, x * ex + y * ey
)
# ...
# Perform routing using exp_ports dictionary
# ...
# Removing the $$$CONTEXT_INFO$$$ top cell (Foundries don't like it)
save_options = pya.SaveLayoutOptions()
save_options.write_context_info = False
# CMC told us to have maximum cell name length of 60 characters
save_options.gds2_max_cellname_length = 60
layout.write("mpw-chip.gds", save_options)
PCells are the foundation of layouts with more than a couple polygons
Routing elements refer to the connections between devices (drawn in PCells). They could be metal traces, optical waveguides, or I/O elements.
The connection between PCells and routing elements are defined in the concept of Ports. The port must contain information on the type of connection, the dimensions of the routing elemenet (e.g. waveguide width), a human-readable name, and positioning.
You probably all know KLayout, but few people make good use of the scripting documentation:
I helped Matthias to release a klayout package in PyPI. It works in a standalone way and is loaded with the Database and Geometry APIs, but not Application or Qt (yet).
pip install klayout
Currently there are pre-built wheels in the following versions:
| OS | Python Version |
|---|---|
| macOS 10.11+ | 2.7, 3.7 |
| macOS 10.13+ | 3.5, 3.6 |
| linux x64, x32 | 2.7, 3.5, 3.6, 3.6 |
| win32, win64 | 3.5, 3.6, 3.7 |
Note for advanced users: You can attempt to build klayout from source by running python setup.py install on the cloned folder from klayout's github repo.
!pip install klayout
import klayout.db as pya
a = pya.DPoint(1, 2)
b = pya.DVector(0, 1)
a+b
Requirement already satisfied: klayout in /Users/tlima/Envs/zeropdk37/lib/python3.7/site-packages (0.26.0.dev16)
1,3
Our lab relies on klayout's database engine to produce masks for MPW manufacturing. To aid collaboration, we open-sourced a tool called zeropdk.
Many foundries only offer PDKs to commercial software with a steep price tag, but are happy to offer libraries of standard components in the .gds format. ZeroPDK allows you to quickly bootstrap a Photonics PDK without necessarily relying on their partners: great for academic users and students. Also great for pro users.
Zeropdk is available with pip install zeropdk and the source code is released in our github page
zeropdk.tech: helps load a tech layer definition from a lyp file.zeropdk.layout: a library of tools for advanced polygon creation (round polygons, waveguides, etc).zeropdk.pcell: contains standard class definitions of PCells, ports and parameters. The idea is to make it compatible with SiEPIC-Tools and Klayout Macro Editor (eventually)!pip install zeropdk
Requirement already satisfied: zeropdk in /Users/tlima/02GitProjects/layout/zeropdk (19.10b0) Requirement already satisfied: numpy in /Users/tlima/Envs/zeropdk37/lib/python3.7/site-packages (from zeropdk) (1.17.0) Requirement already satisfied: klayout in /Users/tlima/Envs/zeropdk37/lib/python3.7/site-packages (from zeropdk) (0.26.0.dev16) Requirement already satisfied: scipy in /Users/tlima/Envs/zeropdk37/lib/python3.7/site-packages (from zeropdk) (1.3.0)
!ls ../demo | grep .lyp
from zeropdk.tech import Tech
EBeam = Tech.load_from_xml('../demo/EBeam.lyp')
EBeam.layers
EBeam.lyp
{'Si': Si (1/0),
'31_Si_p6nm': '31_Si_p6nm' (31/0),
'Text': Text (10/0),
'Si N': 'Si N' (20/0),
'Si N++': 'Si N++' (24/0),
'SEM': SEM (200/0),
'M1': M1 (41/0),
'12_M2': '12_M2' (12/0),
'13_MLopen': '13_MLopen' (13/0),
'VC': VC (40/0),
'M Heater': 'M Heater' (47/0),
'FloorPlan': FloorPlan (99/0),
'DevRec': DevRec (68/0),
'PinRec': PinRec (1/10),
'FbrTgt': FbrTgt (81/0),
'Errors': Errors (999/0),
'Lumerical': Lumerical (733/0),
'Waveguide': Waveguide (1/0)}
import zeropdk.layout.waveguide_rounding as wav_rounding
wav_rounding.main() # produce some interesting non-Manhattan waveguides
Wrote waveguide_rounding.gds
Contents of waveguide_rounding.gds:
!python ../demo/main_python.py
Wrote to example_mask.gds
# !open example_mask.gds
If you have python 3.6+ installed in your computer and are comfortable with installing packages with pip, all we need is pip install zeropdk.
For users without Python 3.6+ setup, I have prepared a docker container with all the necessary packages pre-installed. It is compatible with all OS and runs isolated from your installation. I've tested on macOS and Windows 10.
Mac hardware must be a 2010 or newer model, with Intel’s hardware support for memory management unit (MMU) virtualization, including Extended Page Tables (EPT) and Unrestricted Mode. You can check to see if your machine has this support by running the following command in a terminal: sysctl kern.hv_support
macOS must be version 10.13 or newer. We recommend upgrading to the latest version of macOS.
The first time you start Docker it will pop up a dialog telling you you need an account. You do not need an account. Close the dialog that tells you this: Docker is already running and fully functional. There are thousands of people complaining about the fact that they try to force you to login in order to download/use it.
Open your command line terminal (cmd in Windows) and type:
docker pull felimath/zeropdk
You can check the Docker Image with
docker images
It should show:
REPOSITORY TAG IMAGE ID CREATED SIZE
felimath/zeropdk latest 1082ad385453 About a minute ago 1.42GB
...
This demo's image id: 1082ad385453.
Download the demo files from the workshop's github repo and navigate to the demo folder.
git clone https://github.com/thomaslima/2019-siepic-workshop-zeropdk.git ~/2019-siepic-workshop-zeropdk
If you have cloned the repo, navigate to ~/2019-siepic-workshop-zeropdk/demo with:
cd ~/2019-siepic-workshop-zeropdk/demo
If you don't have git (Windows, or any other reason), feel free to download a zip file directly from github. In my computer, I extracted to the default location and used the following command to get there:
# windows
cd Downloads\2019-siepic-workshop-zeropdk-master\2019-siepic-workshop-zeropdk-master\demo
# bash (unix)
cd ~/Downloads/2019-siepic-workshop-zeropdk-master/demo
From within the demo folder, run the following command in your console
# windows
start-jupyter-windows.bat
# unix
./start-jupyter-unix.sh
Open a browser and go to the highlighted address as shown above. In my case, it was http://127.0.0.1:42019/?token=71e68bae28024c9be4382e6a3f3bd03a0394f678a4e4de2c, but yours will have a different token.
I write all my scripts using python 3.6+ in mind. I did not pay special attention to backwards compatibility with earlier versions. Fixing syntax bugs should be straightforward if you are experienced with python. If you need to use the packages or demos presented here, feel free to submit a pull request to the relevant repositories.
KLayout is an open-source viewer and editor of IC layout files. It has a programming interface with Python and Ruby programming lanaguages. Recently, a pip package was released for the following python distributions:
| OS | Python Version |
|---|---|
| macOS 10.11+ | 2.7, 3.7 |
| macOS 10.13+ | 3.5, 3.6 |
| linux x64, x32 | 2.7, 3.5, 3.6, 3.6 |
| win32, win64 | 3.5, 3.6, 3.7 |
Note for advanced users: You can attempt to build klayout from source by running python setup.py install on the cloned folder from klayout's github repo.
Zeropdk is a python opensource package with basic tools for photonics layout based on the klayout database engine. It is akin to SiEPIC-tools but it was written so that it could be compatible with any foundry's layer stacks. It can also be installed with pip via pip install zeropdk. Alternatively, install from source via the github repo. Documentation is scarce at the moment but hopefully this workshop will be a good start.
If you like Docker and want to build your own Docker image (opensource or closed source), I put the recipe (called Dockerfile) inside the docker-image folder.
Open demo/1. Demo - Using SiEPIC cell library.ipynb
Open demo/2. Demo - MZI PCell.ipynb
One goal: enable collaboration reduce dependence on a single designer or specific computer setup.
Powerpoint presentation in person. Might share here later.